/*Copyright (C) 2013-2022 LZE*/
#include<bits/stdc++.h>
#define fo(x) freopen(#x".in", "r", stdin); freopen(#x".out", "w", stdout);
#define INF 0x7fffffff
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N = 1000010;
const int M = 100010;
ll T, n, m;
ll a[N] = {0}, b[N] = {0}, tag[N] = {0};
ll id[N] = {0}, len;
void update(ll x, ll y, ll k) {
    ll sid = id[x], eid = id[y];
    if(sid == eid) {
        for(ll i = x; i <= y; i++) a[i] += k, b[sid] += k;
        return;
    }
    for(ll i = x; id[i] != sid + 1; i++) a[i] += k, b[sid] += k;
    for(ll i = sid + 1; i < eid; i++) b[i] += len * k, tag[i] += k;
    for(ll i = y; id[i] != eid - 1; i--) a[i] += k, b[eid] += k;
}
ll query(ll x, ll y) {
    ll sid = id[x], eid = id[y], sum = 0;
    if(sid == eid) {
        for(ll i = x; i <= y; i++) sum += (a[i] + tag[sid]);
        return sum;
    }
    for(ll i = x; id[i] != sid + 1; i++) sum += (a[i] + tag[sid]);
    for(ll i = sid + 1; i < eid; i++) sum += b[i];
    for(ll i = y; id[i] != eid - 1; i--) sum += (a[i] + tag[eid]);
    return sum;
}
int main() {
    scanf("%lld%lld", &n, &m);
    len = sqrt(n);
    for(ll i = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
        id[i] = (i - 1) / len + 1;
        b[id[i]] += a[i];
    }
    int opt; ll x, y, k;
    for(ll i = 1; i <= m; i++) {
        scanf("%d%lld%lld", &opt, &x, &y);
        switch(opt) {
            case 1 : { scanf("%lld", &k); update(x, y, k); break; }
            case 2 : { printf("%lld\n", query(x, y)); break; }
        }
    }
    return 0;
}
